package com.openlogic.common.plugins.db.api.plugin;

import java.util.Date;
import java.util.Map;
import java.util.Set;

import org.noear.solon.lang.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.openlogic.common.plugins.db.api.datasource.DataSourceProcessor;
import com.openlogic.common.plugins.spi.enums.DbType;

/**
 * @ClassName: DataSourceProcessorProvider
 * @Description: 数据源处理者Provider，提供接口扩展的入口
 * @author weiyongpeng
 * @date 2024年11月15日 下午4:49:57
 */
public class DataSourceProcessorProvider {

	private static final Logger log = LoggerFactory.getLogger(DataSourceProcessorProvider.class);

	private static final DataSourceProcessorManager dataSourcePluginManager = new DataSourceProcessorManager();

	static {
		log.info("{} - {} - 开始加载扩展服务...", new Date(), Thread.currentThread().getName());
		dataSourcePluginManager.installProcessor();
	}

	private DataSourceProcessorProvider() {
	}

	public static DataSourceProcessor getDataSourceProcessor(@NonNull DbType dbType) {
		return dataSourcePluginManager.getDataSourceProcessorMap().get(dbType.name());
	}

	public static Map<String, DataSourceProcessor> getDataSourceProcessorMap() {
		return dataSourcePluginManager.getDataSourceProcessorMap();
	}
	
	public static Set<String> getDataSourceAllType() {
		return dataSourcePluginManager.getDataSourceTypeSet();
	}
}
